home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 02 Useful Techniques / 08 Zarozinski / src / ffllapi / FuzzyOutVariable.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-28  |  3.9 KB  |  107 lines

  1. //
  2. // File:    FuzzyOutVariable.h
  3. //
  4. // Purpose:    Interface for the FuzzyOutVariable class.   
  5. //
  6. // Copyright ⌐ 1999-2001 Louder Than A Bomb! Software
  7. //
  8. // This file is part of the FFLL (Free Fuzzy Logic Library) project (http://ffll.sourceforge.net)
  9. // It is released under the BSD license, see http://ffll.sourceforge.net/license.txt for the full text.
  10. //
  11.  
  12. #if !defined(AFX_FUZZYOUTVARIABLE_H__71AD4A4D_2C78_414A_B0A5_244D15E0D0A8__INCLUDED_)
  13. #define AFX_FUZZYOUTVARIABLE_H__71AD4A4D_2C78_414A_B0A5_244D15E0D0A8__INCLUDED_
  14.  
  15. #include "FuzzyVariableBase.h"
  16. class FuzzyModelBase;
  17. class FuzzyOutSet;
  18. class DefuzzVarObj;
  19.  
  20. //
  21. // Class:    FuzzyOutVariable
  22. //
  23. // This class is for a model's output variable. It's basedo n FuzzyVariableBase
  24. // and holds information to deal with defuzzification (a process that only applys to
  25. // output variables) and makes sure that the output variable contains FuzzyOutSet objects
  26. // as opposed to the FuzzySetBase that the input variables use.
  27. //
  28. class  FFLL_API FuzzyOutVariable : virtual public FuzzyVariableBase  
  29. {
  30.     ////////////////////////////////////////
  31.     ////////// Member Functions ////////////
  32.     ////////////////////////////////////////
  33.  
  34.     public:
  35.  
  36.         // construct/destruct functions
  37.          FuzzyOutVariable(); // No function body for this. Explicitly disallow auto-creation of it by the compiler
  38.         FuzzyOutVariable(FuzzyModelBase* _parent);
  39.         virtual ~FuzzyOutVariable();
  40.         virtual int init(const wchar_t* _id, RealType _left_x, RealType _right_x, bool create_unique_id = true);
  41.         virtual int init(const wchar_t* _id, bool create_unique_id = true);
  42.  
  43.         // get functions
  44.         int get_defuzz_method();
  45.         int get_composition_method();
  46.         static const char* get_fcl_block_start() ;
  47.         static const char* get_fcl_block_end() ;
  48.         FuzzyOutSet* get_set(int idx) const; 
  49.  
  50.         // set functions
  51.         int set_defuzz_method(int type);
  52.         virtual int set_composition_method(int method);
  53.  
  54.         // misc functions
  55.         FuzzySetBase* new_set();
  56.         virtual bool is_output() const;
  57.         virtual RealType calc_output_value(DOMType* out_set_dom_arr ) const;  
  58.         virtual RealType convert_idx_to_value(int idx) const;
  59.  
  60.     ////////////////////////////////////////
  61.     ////////// Class Variables /////////////
  62.     ////////////////////////////////////////
  63.  
  64.     public:
  65.  
  66.         enum COMPOSITION_OPERATION { MIN, MAX };    // composition is the type of operation to apply to the output set.  When we evaluate the rules, we
  67.                                                     // may have more than one DOM for a single output set.  
  68.                                                     //
  69.                                                     // For (a trivial) example consider a system with 2 input variables and one output
  70.                                                     // variable we may have rules:
  71.                                                     //
  72.                                                     // if var1.set1 and var2.set1 then out.set1
  73.                                                     // if var1.set1 and var2.set2 then out.set1
  74.                                                     //
  75.                                                     // Assume the values:
  76.                                                     //        var1.set1 = .5
  77.                                                     //        var2.set1 = .25
  78.                                                     //        var2.set2 = .75
  79.                                                     //
  80.                                                     // After applying the rules we have 2 values for out.set1:  .25 and .5 (assuming we
  81.                                                     // take the MIN when "anding" the inputs together)
  82.                                                     //
  83.                                                     // We must combine those values via a "composition subprocess" to come up with a single
  84.                                                     // value for the output set.
  85.                                                     // if we use MIN (same as logical AND) we get a value of .25
  86.                                                     // if we use MAX (same as logical OR) we get a value of .5
  87.                                                     //
  88.  
  89.  
  90.     protected:
  91.  
  92.         DefuzzVarObj*    defuzz_obj;    // defuzzification object - this holds the functions to calc the defuzzified
  93.                                     // output value.  Each FuzzyOutSet holds defuzzification specific information
  94.                                     // that the defuzz object can use
  95.  
  96.     private:
  97.  
  98.          int composition_method;    // composition method for this model
  99.  
  100. }; // end class FuzzyOutVariable
  101.  
  102. #else
  103.  
  104. class FuzzyOutVariable; // already included
  105.  
  106. #endif // !defined(AFX_FUZZYOUTVARIABLE_H__71AD4A4D_2C78_414A_B0A5_244D15E0D0A8__INCLUDED_)
  107.